/**
 * 项目名：化工企业安全生产信息化管理平台
 * 日期：    2020-03-01 22:19:07
 * Copyright (c) 2015- -版权所有
 */

package com.joysuch.wwyt.edu.entity;

import static javax.persistence.GenerationType.IDENTITY;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

import com.baomidou.mybatisplus.annotation.TableName;
import com.joysuch.wwyt.core.support.AutoSetCommonFieldListener;
import lombok.Data;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.Where;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import java.util.Date;

@EntityListeners({ AuditingEntityListener.class, AutoSetCommonFieldListener.class })
@Entity
@Table(name = "wwyt_edu_exam")
@SQLDelete(sql = "update wwyt_edu_exam set DELETE_FLAG = '1' where id= ?")
@SQLDeleteAll(sql = "update wwyt_edu_exam set DELETE_FLAG = '1' where id= ?")
@Where(clause = "DELETE_FLAG = '0'")
@Data
@TableName("wwyt_edu_exam")
public class EduExam implements java.io.Serializable {

    // columns START
    @Id
    @GeneratedValue(strategy = IDENTITY)

    // ID
    @Column(name = "ID", unique = true, nullable = false)
    private Long id;

    // 编号
    @Column(name = "CODE", length = 10)
    private String code;

    // 名称
    @Column(name = "NAME", length = 100)
    private String name;

    // 类型
    @Column(name = "TYPE_ID")
    private Long typeId;

    // 时长（分钟）
    @Column(name = "DURATION_MINUTES")
    private Integer durationMinutes;

    // 创建人名称
    @Column(name = "CREATE_USER_NAME", length = 20)
    private String createUserName;

    // 考试开始日期
    @Column(name = "START_TIME")
    private java.util.Date startTime;

    // 考试截止日期
    @Column(name = "END_TIME")
    private java.util.Date endTime;

    // 简介
    @Column(name = "INTRODUCTION", length = 65535)
    private String introduction;

    // 参与对象类型
    @Column(name = "JOIN_IN_ORG_TYPE", length = 5)
    private String joinInOrgType;

    // 参与对象数量
    @Column(name = "JOIN_IN_COUNT")
    private Integer joinInCount;

    // 创建人
    @org.springframework.data.annotation.CreatedBy
    @Column(name = "CREATE_BY")
    private Long createBy;

    // 创建时间
    @Column(name = "CREATE_TIME")
    private java.util.Date createTime;

    // 更新人
    @org.springframework.data.annotation.LastModifiedBy
    @Column(name = "UPDATE_BY")
    private Long updateBy;

    // 更新时间
    @org.springframework.data.annotation.LastModifiedDate
    @Column(name = "UPDATE_TIME")
    private java.util.Date updateTime;

    // 删除标记
    @Column(name = "DELETE_FLAG", length = 2)
    private String deleteFlag;

    // 组织机构代码
    @Column(name = "ORG_CODE", length = 100)
    private String orgCode;

    @Column(name = "STATE")
    private Integer state;
    // 租户
    @Column(name = "TENENT_ID")
    private Long tenentId;
    // 考题随机排列
    @Column(name = "RANDOMIZE_QUESTION")
    private Integer randomizeQuestion;

    // 是否允许重考,Y:是，N：否 A:随时可重考
    @Column(name = "ALLOW_TRY_AGAIN", length = 1)
    private String allowTryAgain;
    // 是否限制可重考次数："Y"、"N"
    @Column(name = "TRY_AGAIN_LIMIT_FLAG", length = 1)
    private String tryAgainLimitFlag;
    // 可重试次数
    @Column(name = "TRY_AGAIN_LIMIT")
    private Integer tryAgainLimit;
    // 考试记录是否显示答案, Y: 是，N：否
    @Column(name = "SHOW_ANSWER_IN_RECORD", length = 1)
    private String showAnswerInRecord;
    // 阅卷人员id
    @Column(name = "EXAMINER_USER_IDS")
    private String examinerUserIds;

    /**
     * 考试模式 1 自由考试 2 先学再考
     */
    @Column(name = "EXAM_MODE")
    private Integer examMode;

    /**
     * 重考是否随机(1-随机 0-不随机)
     */
    @Column(name = "RANDOMIZE_QUESTION_RESIT")
    private Integer randomizeQuestionResit;

    //是否开启人脸识别 0关闭 1开启
    @Column(name = "OPEN_FACE")
    private Integer openFace;

    //是否需要显示签名 0 不需要显示  1显示
    @Column(name = "show_autograph")
    private Integer showAutograph;

    //线上考试（1 线上 0 线下)
    @Column(name = "FORM_TYPE")
    private Integer formType;
    //是否关联培训(1 是 0否)
    @Column(name = "TRAIN_TYPE")
    private Integer trainType;
    //考试地点
    @Column(name = "LOCATION")
    private String location;
    //总分
    @Column(name = "TOTAL_SCORE")
    private Float totalScore;
    //及格分数
    @Column(name = "PASS_SCORE")
    private Float passScore;
    // 发布时间
    @Column(name = "RELEASE_TIME")
    private Date releaseTime;
    // columns END

    public int hashCode() {
        return new HashCodeBuilder().append(getId()).toHashCode();
    }

    public boolean equals(Object obj) {
        if (obj instanceof EduExam == false)
            return false;
        if (this == obj)
            return true;
        EduExam other = (EduExam) obj;
        return new EqualsBuilder().append(getId(), other.getId()).isEquals();
    }
}
